__author__ = "Alexandre Lessard"
__copyright__ = "Copyright 2011, Alexandre Lessard"
__credits__ = [""]
__license__ = "BSD"
__version__ = "0.0.1"
__maintainer__ = "Alexandre Lessard"
__email__ = "alexandre.lessard.ti@gmail.com"
__status__ = "Prototype"

"""Base Controller module as a starup for any controllers"""
#Import system
from flask import abort
from simpleAppsSME import app

class BaseController:
    """Base class for all controllers"""
    
    def route(self, method, contact_id):
        """Startup method for the controller
        used to route to target method"""
        
        if method == None:
            return self.index(contact_id)
        
        #Call the page asked or show a 404 if it don't exist    
        callmethod = getattr(self,method, self.error_404)
        return callmethod(contact_id)
    
    def error_404(self, contact_id):
        abort(404)
        this_is_never_executed()